package com.lx.oms.controller.service.impl;

import java.math.BigInteger;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lx.oms.common.entity.Page;
import com.lx.oms.common.entity.Query;
import com.lx.oms.common.entity.R;
import com.lx.oms.common.utils.CommonUtils;
import com.lx.oms.controller.entity.FactoryEntity;
import com.lx.oms.controller.manager.FactoryManager;
import com.lx.oms.controller.service.FactoryService;

/**
 * 厂名
 *
 * @author houzhong
 * @date 2018年10月24日 下午1:26:13
 */
@Service("factoryService")
public class FactoryServiceImpl implements FactoryService {

	@Autowired
	private FactoryManager factoryManager;

	@Override
	public Page<FactoryEntity> listFactory(Map<String, Object> params) {
		Query query = new Query(params);
		Page<FactoryEntity> page = new Page<>(query);
		factoryManager.listFactory(page, query);
		return page;
	}

	@Override
	public R saveFactory(FactoryEntity role) {
		int count = factoryManager.saveFactory(role);
		return CommonUtils.msg(count);
	}

	@Override
	public R getFactoryById(BigInteger id) {
		FactoryEntity tFactory = factoryManager.getFactoryById(id);
		return CommonUtils.msg(tFactory);
	}

	@Override
	public R updateFactory(FactoryEntity tFactory) {
		int count = factoryManager.updateFactory(tFactory);
		return CommonUtils.msg(count);
	}

	@Override
	public R batchRemove(String[] id) {
		int count = factoryManager.batchRemove(id);
		return CommonUtils.msg(id, count);
	}

	@Override
	public FactoryEntity getFactoryByName(String name) {
		FactoryEntity tFactory = factoryManager.getFactoryByName(name);
		return tFactory;
	}

	@Override
	public List<FactoryEntity> listByFactory(Map<String, Object> params) {
		Query query = new Query(params);
		return factoryManager.listByFactory(query);
	}

}
